class Solution
{
public:
    bool checkRecord(string s)
    {
        int ACount = 0;
        int continuousL = 0;
        for (char c : s)
        {
            if (c == 'L')
            {
                ++continuousL;
                if (continuousL >= 3)
                {
                    return false;
                }
            }
            else
            {
                continuousL = 0;
            }

            if (c == 'A')
            {
                ++ACount;
                if (ACount >= 2)
                {
                    return false;
                }
            }
        }
        return true;
    }
};